package com.example.petcare.mapper;


import com.example.petcare.pojo.Pet;
import com.example.petcare.pojo.Review;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ReviewMapper {

    // 添加评论
    @Insert("INSERT INTO review (host_id, rating, feedback, review_pics, review_time,provider_id) VALUES (#{hostId}, #{rating}, #{feedback}, #{reviewPics}, #{reviewTime}, #{providerId})")
    void addReview(Review review);

    // 根据hostId查询评论
    @Select("SELECT * FROM review WHERE host_id = #{hostId}")
    Review getReviewByHostId(Integer hostId);


    // 根据providerId查询评论(最近5条)
    @Select("SELECT * FROM review WHERE provider_id = #{providerId} ORDER BY review_time DESC LIMIT 5")
    List<Review> getReviewByProviderId(Integer providerId);
}
